
<script type="text/javascript">
    $(document).ready(function(){
        $('#user-panel-form').validate({
            errorElement: 'span',
            rules:{
                password2:{
                    equalTo:'#password1'
                }
            }
        });
        $('#frm_Reg').validate({
            errorElement: 'em',
            rules:{
                password2P:{
                    equalTo:'#password1P'
                }
            }
        });
    });
	
	
</script>
<div id="user-panel" class="user-panel-collapsed">
    <div id="user-panel-content">
        <div id="user-panel-inner">
            <div class="up-col-1"></div>
            <div class="up-col-2">
                <form id="user-panel-form" name="user_panel_form" action="" method="post">
                    <div class="form-field" style="width: 800px">
                        <label for="login_62" class="main_label cm-required cm-email">E-mail:</label>
                        <input type="text" id="login_62" name="userEmail" size="30" value="" class="cm-focus input-text email required">
                    </div>

                    <div class="form-field">
                        <label class="main_label">Bạn đã có tài khoản?</label>
                        <div style="overflow: hidden" >
                            <span style="line-height: 24px">
                                <input class="cm-combinations_have_account" type="radio" id="sw_off_have_account_62" name="have_account" value="N"> 
                                <label for="sw_off_have_account_62" class="html-label">Không, tạo một tài khoản ngay bây giờ</label>
                            </span>
                            <br style="clear:both">
                            <span style="line-height: 24px">
                                <input class="cm-combinations_have_account" type="radio" checked="checked" id="sw_on_have_account_62" name="have_account" value="Y">
                                <label for="sw_on_have_account_62" class="html-label">Có, mật khẩu của tôi là:</label>
                            </span>
                        </div>
                    </div>

                    <div id="on_have_account">
                        <div class="form-field" style="width: 800px">
                            <label for="psw_62" class="main_label cm-required">Mật Khẩu: </label>
                            <input type="password" id="psw_62" name="password" size="30" maxlength="12" minlength="6" value="" class="input-text required">
                        </div>

                        <div class="clear">
                            <div class="p-button p-button-red" style="margin: 5px 0 0 165px; display: inline;">
                                <input type="submit" class="p-button-start" value="Đăng nhập" name="login">
                                <div class="p-button-end"></div>
                            </div>
                        </div>
                    </div>

                    <div id="off_have_account" class="hi">
                        <div class="form-field" style="width: 800px">
                            <label for="elm_25" class=" cm-state cm-location-shipping">Danh Xưng:</label>
                            <select id="elm_25" name="danhxung" class="select_state " >
                                <option value="">- Chọn Danh Xưng -</option>
                                <option value="1">Ông</option>
                                <option value="2">Bà</option>
                            </select>
                        </div>
                        <div class="form-field" style="width: 800px">
                            <label for="password1" class="cm-required cm-password">Mật khẩu:</label>
                            <input type="password" id="password1" name="password1" size="30" maxlength="12" minlength="6" value="" class="input-text required" autocomplete="off">
                        </div>
                        <div class="form-field" style="width: 800px">
                            <label for="password2" class="cm-required cm-password">Nhập lại mật khẩu:</label>
                            <input type="password" id="password2" name="password2" size="30" maxlength="12" minlength="6" value="" class="input-text required" autocomplete="off">
                        </div>
                        <div class="sep-line" style="width:90%"></div>

                        <div class="form-field" style="width: 800px">
                            <label for="elm_6" class="cm-required ">Họ và Tên:</label>
                            <input type="text" id="elm_6" name="fullName" size="30" value="" class="input-text required" >
                        </div>

                        <div class="form-field" style="width: 800px">
                            <label for="elm_44" class=" ">Điện thoại liên hệ:</label>
                            <input type="text" id="elm_44" name="phone" size="30" value="" class="input-text required digits" >
                        </div> 

                        <div class="form-field" style="width: 800px">
                            <label for="elm_44" class=" ">Địa chỉ:</label>
                            <input type="text" id="elm_44" name="address" size="30" value="" class="input-text required" >
                        </div> 

                        

                        <div class="shipping_info">
                            <div class="form-field">
                                <label for="elm_25" class=" cm-state cm-location-shipping">Tỉnh/ Thành:</label>
                                <select id="elm_25" name="provinceID" class="select_state" >
                                    <option value="">- Chọn Tỉnh/thành -</option>
                                    <?php foreach ($this->tinh as $t) { ?>
                                        <option value="<?php echo $t['matinh']; ?>"><?php echo $t['tentinh']; ?></option>
                                    <?php } ?>
                                </select>
                                <span>&nbsp;
<!--                                    <script type="text/javascript">
                                        //<![CDATA[
        
                                        if (!($.browser.msie && /6.0/.test(navigator.userAgent))) {
        
                                            default_state['shipping'] = 'VN';
        
                                        }
                                        //]]>
                                    </script>-->
                                </span>
                            </div>

                        </div>
                        <div class="clear">
                            <div class="form-button">
                                <div class="p-button p-button-red">
                                    <input type="submit" class="p-button-start cm-check-user-panel-resize" value="Đăng ký tài khoản" name="addUserPup" id="save_profile_but">
                                    <div class="p-button-end"></div>
                                </div>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>

        <?php if (isset($_SESSION['userID'])) { ?>
            <div id="user-panel-buttons">
                <div style="cursor: pointer;" class="button profile-button" onmouseover="showuser();" onmouseout="hideuser();">
                    <span class="button-inner"> 
                        <?php echo $_SESSION['userName']; ?>
                    </span>
                </div>
            </div>
            <script type="text/javascript">
                function showuser(){
                    $('#user-panel-dropdown').removeClass('hidden');
                }
                function hideuser(){
                    $('#user-panel-dropdown').addClass('hidden');
                }    
            </script>
            <div id="user-panel-dropdown" class="hidden" onmouseover="showuser();" onmouseout="hideuser();">
                <div id="user-panel-info">
                    <div id="user-panel-info-username" class="clear">
                        <img src="<?php echo $_SESSION['userAvatar']; ?>" alt="avatar" width="100px" height="100px"  /><br />
                        <strong><?php echo $_SESSION['userName']; ?></strong>
                    </div>
                </div>
                <div id="user-panel-actions">
                    <ul>
                        <li>
                            <img src="Media/image/icon-profile.png"/>
                            <a href="userProfile.php">
                                <span>Tài khoản</span>
                            </a>
                        </li>
                        <?php if (isset($_SESSION['userRole']) && $_SESSION['userRole'] == 3) { ?>
                            <li>
                                <img src="Media/image/icon-orders.png"/>
                                <a href="donhang.php">
                                    <span>Quản lý đơn hàng</span>
                                </a>
                            </li>
                        <?php } ?>
                        <li>
                            <img src="Media/image/icon-password.png"/>
                            <a href="userProfile.php">Đổi mật khẩu</a>
                        </li>

                        <li>
                            <img src="Media/image/icon-signout.png"/>
                            <a href="Layout/logout.php">Đăng xuất</a>
                        </li>
                    </ul>
                </div>
                <div class="line"/></div>
        </div>
    <?php } else { ?>
        <div id="user-panel-buttons">
            <a class="button up-login-register-button" href="">
                <span class="button-inner"> 
                    Đăng nhập hoặc đăng ký
                </span>
            </a>
        </div>
    <?php } ?>
</div>
</div>
